<template>
  <view>
	  <!-- 公共组件-每个页面必须引入 -->
	  <public-module></public-module>
      <view class="checkIn-business" v-if="isEdit">
	     <u--form class="u-form" labelPosition="left" labelWidth='180rpx' :model="model1" :rules="rules" ref="uForm" errorType="toast">
		   <u-form-item label=" " :borderBottom="false" prop="storeBusinessLicense" labelWidth="0">
			 <div class="form-bg">
				 <u-form-item label="店铺类型" prop="storeType" :borderBottom="false"  @click='changeStore' required>
				   <u--input v-model="model1.storeType" input-align="right" disabled disabledColor="#ffffff" placeholder="选择店铺类型"
				     border="none" style="pointer-events: none"></u--input>
				  <div  slot="right">
					   <u-icon slot="right" name="arrow-right"></u-icon>
				  </div> 
				 </u-form-item>
			 </div>
			  <div style="height:32rpx;"></div>
			 <div class="form-bg">
				 <div style="font-weight: bold;padding-top:24rpx"  v-if="model1.storeType != ''">
					{{typeList[storeType]['name']}}类别请上传经营时间{{typeList[storeType]['year']}}年以上的营业执照
				 </div>
				 <div style="font-weight: bold;padding-top:24rpx"  v-else>
					请选择店铺类型后上传对应要求的营业执照
				 </div>
				 <view class="checkIn-cname">
					<view class="checkIn-update">
					  <view class="checkIn-update-img" style="width: 150px;height: 90px;margin:0 auto">
						<u-upload url="https://upload.qiniup.com" :fileList="fileList1" @afterRead="handleAfterRead($event,'storeBusinessLicense')" 
						  name="1"  :maxCount="1" style="width: 250px;height: 150px;margin:0 auto" :disabled="model1.storeType == ''">
						  <img :src="model1.storeBusinessLicense ? model1.storeBusinessLicense : 'https://pic.gxmore.com/FiqGX7sq-tf7AxckbXJHCroBW1Pv'"  style="width: 150px;height: 90px;"></img>
						</u-upload>
					  </view>
					  <view style="padding:10rpx 0">
						<span style="color:red;">*</span>营业执照自动识别，格式为jpg大小2m以内
					  </view>
					</view>
				 </view>
			 </div>  
		   </u-form-item>
	       <div class="form-bg">
					<u-form-item label="公司名称" borderBottom>
					   <div style="text-align: right;">{{model1.storeName}}</div>
				   </u-form-item>
				   <u-form-item label="统一信用码" borderBottom>
					   <div style="text-align: right;">{{model1.storeCode}}</div>
				   </u-form-item>
				  <!-- <u-form-item label="公司地址" prop="storeArea" borderBottom required>
					  <uni-data-picker v-slot:default placeholder="请选择所在地区" popup-title="请选择所在地区" :localdata="dataTree"
						 :map="{text:'areaName',value:'areaId'}" @change="onchange" :clear-icon="false" style="width:100%">
						 <u--input v-model="model1.storeArea" input-align="right" disabled disabledColor="#ffffff"
						   placeholder="请选择所在地区" border="none"></u--input>
					   </uni-data-picker>
					   
					   <div  slot="right">
						   <u-icon slot="right" name="arrow-right" :customStyle="{marginRight: '10px'}"></u-icon>
					   </div>
				 </u-form-item>
				 <u-form-item label="详细地址" prop="storeAddress" :borderBottom="false"  required>
				   <u--input v-model="model1.storeAddress" input-align="right"  :customStyle="{marginRight: '20px'}"
					 placeholder="请输入详细地址" border="none"></u--input>
				 </u-form-item> -->
			  </div>
			  
	  	      <div style="height:32rpx;"></div>
			  <div class="form-bg">
				  <u-form-item label="联系人" prop="contactPerson" borderBottom required>
						<u--input v-model="model1.contactPerson" input-align="right"  placeholder="请输入联系人" border="none"></u--input>
				  </u-form-item>
				  <u-form-item label="联系人电话" prop="storePhone" :borderBottom="false" required>
						<u--input v-model="model1.storePhone" input-align="right"  placeholder="请输入联系人电话" border="none"></u--input>
				  </u-form-item>
			  </div>
			  
			  <div style="height:32rpx;"></div>
			  <div class="form-bg">
				  <u-form-item label="主营品类" prop="mainBusiness" borderBottom @click="showMainBu" required>
				    <u--input v-model="model1.mainBusiness" input-align="right" disabled disabledColor="#ffffff"
				      placeholder="请选择主营品类" border="none" style="pointer-events: none"></u--input>
				    <div  slot="right">
					   <u-icon slot="right" name="arrow-right" ></u-icon>
				    </div>
				  </u-form-item>
				 
			  </div>
			  
			  <div style="height:32rpx;" ></div>
			  <div class="form-bg">
				  <u-form-item label="实体经营地址照片" prop="businessAddressImg" :borderBottom="false"   required labelPosition="top" labelWidth='300rpx'>
					  <div style="width:200rpx;margin:0 auto">
						  <u-upload url="https://upload.qiniup.com" :fileList="fileList1" @afterRead="handleAfterRead($event,'businessAddressImg')" 
							name="2"  :maxCount="1" style="width:200rpx;height:200rpx;">
							<img :src="model1.businessAddressImg" v-if="model1.businessAddressImg" style="width:200rpx;height:200rpx;"></img>
							<div v-else style="border:1px solid #eee;width:200rpx;height:200rpx;margin:0 auto;display: flex;justify-content: center;align-items: center;">
							  <u-icon name="plus" size="30"></u-icon>
							</div>
						  </u-upload>
				
					  </div>
					  <div style="padding:10rpx 0;text-align: center;font-size:24rpx;" >与营业执照抬头内容相同实体经营门面照片或工厂大门照片</div>
				  
				  </u-form-item>
			  </div>
			  
			  <!--生产厂家-->
			  <div style="height:32rpx;" v-if="storeType == 1"></div>
			  <div class="form-bg" v-if="storeType == 1">
				  <u-form-item label="授权书" prop="empowerBook" :borderBottom="false"   required labelPosition="top">
					  <div style="width:200rpx;margin:0 auto">
						  <u-upload url="https://upload.qiniup.com" :fileList="fileList1" @afterRead="handleAfterRead($event,'empowerBook')" 
						    name="2"  :maxCount="1" style="width:200rpx;height:200rpx;">
						    <img :src="model1.empowerBook" v-if="model1.empowerBook" style="width:200rpx;height:200rpx;"></img>
						    <div v-else style="border:1px solid #eee;width:200rpx;height:200rpx;margin:0 auto;display: flex;justify-content: center;align-items: center;">
						  	  <u-icon name="plus" size="30"></u-icon>
						    </div>
						  </u-upload>
						  <div style="padding:10rpx 0;text-align: center;font-size:24rpx;color:#FF5E01" @click="downImg">下载授权书模板</div>
					  </div>
				      <div style="padding:10rpx 0;text-align: center;font-size:24rpx">工厂盖章的授权书内容参考下载的授权书模板</div>
				  </u-form-item>
			  </div>
			  <!--品牌代理-->
			  <div v-if="storeType == 2">
				  <div style="height:32rpx;"></div>
				  <div class="form-bg">
					  <u-form-item label="品牌代理证明" prop="brandAgency" :borderBottom="false"   required labelPosition="top">
						  <div style="width:200rpx;margin:0 auto">
							  <u-upload url="https://upload.qiniup.com" :fileList="fileList1" @afterRead="handleAfterRead($event,'brandAgency')" 
								name="3"  :maxCount="1" style="width:200rpx;height:200rpx;">
								<img :src="model1.brandAgency" v-if="model1.brandAgency" style="width:200rpx;height:200rpx;"></img>
								<div v-else style="border:1px solid #eee;width:200rpx;height:200rpx;margin:0 auto;display: flex;justify-content: center;align-items: center;">
								  <u-icon name="plus" size="30"></u-icon>
								</div>
							  </u-upload>
						  </div>
					  <div style="padding:10rpx 0;text-align: center;font-size:24rpx">生产厂家授权的代理证或加盖生产厂家公章的授权经销资料</div>
					  </u-form-item>
				  </div>
			  </div>
			  <!--优质贸易商-->
			  <div v-if="storeType == 3">
				  <div style="height:32rpx;"></div>
				  <div class="form-bg">
					  <u-form-item label="采购渠道证明" prop="procurementChannels" :borderBottom="false"   required labelPosition="top">
						  <div style="width:200rpx;margin:0 auto">
							  <u-upload url="https://upload.qiniup.com" :fileList="fileList1" @afterRead="handleAfterRead($event,'procurementChannels')" 
								name="4"  :maxCount="1" style="width:200rpx;height:200rpx;">
								<img :src="model1.procurementChannels" v-if="model1.procurementChannels" style="width:200rpx;height:200rpx;"></img>
								<div v-else style="border:1px solid #eee;width:200rpx;height:200rpx;margin:0 auto;display: flex;justify-content: center;align-items: center;">
								  <u-icon name="plus" size="30"></u-icon>
								</div>
							  </u-upload>
						  </div>
						  <div style="padding:10rpx 0;text-align: center;font-size:24rpx">具有生产厂家与申请方盖章的原料购销合同或有双方抬头的购销发票证明</div>
					  
					  </u-form-item>
				  </div>
			  </div>
			  <div style="height:32rpx;"></div>
			  <div class="form-bg">
				  <u-form-item label="联系电话"  borderBottom >
						<u--input  v-model="model1.invoicePhone" input-align="right"  placeholder="请输入开票信息联系电话" border="none"></u--input>
				  </u-form-item>
				  <u-form-item label="开户行"  borderBottom >
						<u--input  v-model="model1.bankName" input-align="right"   placeholder="请输入开票信息开户行" border="none"></u--input>
				  </u-form-item>
				  <u-form-item label="银行帐号"  borderBottom >
						<u--input  v-model="model1.bankNumber" input-align="right" 
						  placeholder="请输入开票信息银行帐号" border="none"></u--input>
				  </u-form-item>
				  <u-form-item label="注册地址" :borderBottom="false"  >
					<u--input v-model="model1.registerAddress" input-align="right"  
									 placeholder="请输入开票信息注册地址" border="none"></u--input>
				  </u-form-item>
			  </div>
			  
			  <div style="height:32rpx;"></div>
			  <div class="form-bg">
				  <u-form-item label="网址"  borderBottom >
						<u--input  v-model="model1.website" input-align="right"   placeholder="可以正常访问的官网链接" border="none"></u--input>
				  </u-form-item>
			  </div>
			  
			  <div style="height:32rpx;"></div>
			  <div class="form-bg">
				  <u-form-item label="仓库照片"  :borderBottom="false"  labelPosition="top">
					  <div style="margin-top:20rpx" >
						  <u-upload url="https://upload.qiniup.com" @delete="deleteImg($event,'warehouseImg')" :maxCount="6" :fileList="model1.warehouseImg" @afterRead="handleAfterRead2($event,'warehouseImg')" ></u-upload>
						  <div style="text-align: center;font-size: 24rpx;padding:24rpx 0">最多上传6张图片</div>
					  </div>
				 </u-form-item>
			  </div>
			  
			  <div style="height:32rpx;"></div>
			  <div class="form-bg">
				  <u-form-item label="技术专利"  :borderBottom="false"  labelPosition="top">
					  <div style="margin-top:20rpx" >
						  <u-upload url="https://upload.qiniup.com" @delete="deleteImg($event,'technicalPatentsImg')" :maxCount="6" :fileList="model1.technicalPatentsImg" @afterRead="handleAfterRead2($event,'technicalPatentsImg')" ></u-upload>
						  <div style="text-align: center;font-size: 24rpx;padding:24rpx 0">最多上传6张图片</div>
					  </div>
				 </u-form-item>
			  </div>
			  
			  <div style="height:32rpx;"></div>
			  <div class="form-bg">
				  <u-form-item label="荣誉资质"  :borderBottom="false"  labelPosition="top">
					  <div style="margin-top:20rpx" >
						  <u-upload url="https://upload.qiniup.com" @delete="deleteImg($event,'honorImg')" :maxCount="6" :fileList="model1.honorImg" @afterRead="handleAfterRead2($event,'honorImg')" ></u-upload>
						  <div style="text-align: center;font-size: 24rpx;padding:24rpx 0">最多上传6张图片</div>
					  </div>
				 </u-form-item>
			  </div>  
	   </u--form>
      <view class="checkIn-auth-button">
         <u-button type="primary" shape="circle" @click="addEditStore" v-if="isEdit">提交入驻</u-button>
      </view>
    </view>
	<div class="checkIn-info"  v-else>
		<div class="checkIn-state">
			<div v-if="storeState == 0">
				<img src="https://pic.moresu.com/FhvjIwgEEswHK9MIl1-hgS7XErja"  style="vertical-align: middle;width: 60rpx;height: 59rpx;display: inline-block;" mode="aspectFit"></img>
				<span style="padding-left:20rpx;vertical-align: middle;">审核中</span>
			</div>
			<div v-if="storeState == 2">
				<img src="https://pic.moresu.com/FqVkjQ6FtB6eaKnf36kV0jhKz3WA"  style="vertical-align: middle;width: 60rpx;height: 59rpx;display: inline-block;" mode="aspectFit"></img>
				<span style="padding-left:20rpx;vertical-align: middle;">审核不通过</span>
				<div class="state-stext">{{model1.checkRemark}}</div>
			</div>	
		</div>
	    <u--form class="u-form" labelPosition="left" labelWidth='180rpx' :model="model1" ref="uForm1" >
			   <u-form-item label=" " borderBottom labelWidth="0">
					<img @click="preview(model1.storeBusinessLicense)" :src="model1.storeBusinessLicense ? model1.storeBusinessLicense : 'https://pic.gxmore.com/FiqGX7sq-tf7AxckbXJHCroBW1Pv'"  style="width: 414rpx;height: 270rpx;margin:0 auto;display: block;" mode="aspectFit"></img>
					<div style="font-size:28rpx;padding-top:20rpx;text-align: center;font-weight: bold;">营业执照</div>
			   </u-form-item>
				<u-form-item label="公司名称" borderBottom>
				   <div style="text-align: right;">{{model1.storeName}}</div>
			   </u-form-item>
			   <u-form-item label="统一信用码" borderBottom>
				   <div style="text-align: right;">{{model1.storeCode}}</div>
			   </u-form-item>
			   <u-form-item label="注册地址" borderBottom  >
					 <div style="text-align: right;">{{model1.registerAddress}}</div>
			   </u-form-item>
			   <u-form-item label="网址" borderBottom>
				   <div style="text-align: right;">{{model1.website}}</div>
			   </u-form-item>
			 <!-- <u-form-item label="公司地址" borderBottom >
				  <div style="text-align: right;">{{model1.storeArea}}</div>
			 </u-form-item>
			 <u-form-item label="详细地址"  borderBottom>
				 <div style="text-align: right;">{{model1.storeAddress}}</div>
			 </u-form-item> -->
			  <u-form-item label="联系电话"  borderBottom>
				   <div style="text-align: right;">{{model1.invoicePhone}}</div>
			  </u-form-item>
			  <u-form-item label="开户行"  borderBottom>
				  <div style="text-align: right;">{{model1.bankName}}</div>
			  </u-form-item>
			  <u-form-item label="银行帐号" borderBottom>
				  <div style="text-align: right;">{{model1.bankNumber}}</div>
			  </u-form-item> 
			  <u-form-item label="联系人"  borderBottom >
				  <div style="text-align: right;">{{model1.contactPerson}}</div>	
			  </u-form-item>
			  <u-form-item label="联系人电话"  borderBottom >
				  <div style="text-align: right;">{{model1.storePhone}}</div>
			  </u-form-item>
			  <u-form-item label="主营品类"  borderBottom >
				  <div style="text-align: right;word-break: break-all;">{{model1.mainBusiness}}</div>
			  </u-form-item>
			  <u-form-item label="店铺类型" borderBottom>
				   <div style="text-align: right;">{{model1.storeType}}</div>
			  </u-form-item>
			  
			  <u-form-item label=" "  labelWidth="0" borderBottom>
				   <img @click="preview(model1.businessAddressImg)" :src="model1.businessAddressImg ? model1.businessAddressImg : 'https://pic.gxmore.com/FiqGX7sq-tf7AxckbXJHCroBW1Pv'"  style="width: 414rpx;height: 270rpx;margin:0 auto;display: block;" mode="aspectFit"></img>
				   <div style="font-size:28rpx;padding-top:20rpx;text-align: center;font-weight: bold;">实体经营地址照片</div>
			  </u-form-item>
			  
			  
			  <u-form-item label=" "  labelWidth="0" borderBottom v-if="storeType == 1">
				   <img @click="preview(model1.empowerBook)" :src="model1.empowerBook ? model1.empowerBook : 'https://pic.gxmore.com/FiqGX7sq-tf7AxckbXJHCroBW1Pv'"  style="width: 414rpx;height: 270rpx;margin:0 auto;display: block;" mode="aspectFit"></img>
				   <div style="font-size:28rpx;padding-top:20rpx;text-align: center;font-weight: bold;">授权书</div>
			  </u-form-item>
			  <u-form-item label=" " borderBottom labelWidth="0" v-if="storeType == 2">
					<img @click="preview(model1.brandAgency)" :src="model1.brandAgency ? model1.brandAgency : 'https://pic.gxmore.com/FiqGX7sq-tf7AxckbXJHCroBW1Pv'"  style="width: 414rpx;height: 270rpx;margin:0 auto;display: block;" mode="aspectFit"></img>
				   <div style="font-size:28rpx;padding-top:20rpx;text-align: center;font-weight: bold;">品牌代理证明</div>
			  </u-form-item>
			  
			  <u-form-item label=" " borderBottom labelWidth="0" v-if="storeType == 3">
					<img @click="preview(model1.procurementChannels)" :src="model1.procurementChannels ? model1.procurementChannels : 'https://pic.gxmore.com/FiqGX7sq-tf7AxckbXJHCroBW1Pv'"  style="width: 414rpx;height: 270rpx;margin:0 auto;display: block;" mode="aspectFit"></img>
				   <div style="font-size:28rpx;padding-top:20rpx;text-align: center;font-weight: bold;">采购渠道证明</div>
			  </u-form-item>  
			 
			  <div style="height:32rpx;"></div>
			  <div class="form-bg">
				  <u-form-item label="仓库照片"  :borderBottom="false"  labelPosition="top">
					  <div style="margin-top:20rpx;display: flex;flex-direction: row;flex-wrap: wrap;flex: 1;" >
						  <div  v-for="ee in model1.warehouseImg" :key="ee" style="border-radius: 2px;margin: 0 8px 8px 0;position: relative;overflow: hidden;display: flex;flex-direction: row;">
							  <img @click="preview2(model1.warehouseImg)" :src="ee.url"  style="width: 160rpx;height: 160rpx;margin-right:10px;" mode="aspectFit"></img>
						  </div>	 
					  </div>
				 </u-form-item>
			  </div>
			  
			  <div style="height:32rpx;"></div>
			  <div class="form-bg">
				  <u-form-item label="技术专利"  :borderBottom="false"  labelPosition="top">
					  <div style="margin-top:20rpx;display: flex;flex-direction: row;flex-wrap: wrap;flex: 1;" >
						  <div  v-for="ee in model1.technicalPatentsImg" :key="ee" style="border-radius: 2px;margin: 0 8px 8px 0;position: relative;overflow: hidden;display: flex;flex-direction: row;">
							  <img @click="preview2(model1.technicalPatentsImg)" :src="ee.url"  style="width: 160rpx;height: 160rpx;margin-right:10px;" mode="aspectFit"></img>
						  </div>	 
					  </div>
				 </u-form-item>
			  </div>
			  
			  <div style="height:32rpx;"></div>
			  <div class="form-bg">
				  <u-form-item label="荣誉资质"  :borderBottom="false"  labelPosition="top">
					  <div style="margin-top:20rpx;display: flex;flex-direction: row;flex-wrap: wrap;flex: 1;" >
						  <div  v-for="ee in model1.honorImg" :key="ee" style="border-radius: 2px;margin: 0 8px 8px 0;position: relative;overflow: hidden;display: flex;flex-direction: row;">
							  <img @click="preview2(model1.honorImg)" :src="ee.url"  style="width: 160rpx;height: 160rpx;margin-right:10px;" mode="aspectFit"></img>
						  </div>	 
					  </div>
				 </u-form-item>
			  </div>
			 
	    </u--form>  
		<view v-if="storeState == 2 " style="position: fixed;bottom:0;padding:24rpx;width:100%;box-sizing: border-box;left:0;background: #fff;">
		    <u-button type="primary" shape="circle" @click="isEdit = true" >修改资料</u-button>
		</view>
	</div>
    
	
   <!-- 公司类型 -->
   <u-picker :show="showStoreType" :columns="columns" keyName="value" @confirm='confirmStoreType'
     @cancel='cancelStoreType'></u-picker>
   <!--品名-->
   <category ref="category" @chooseItem="chooseCategory"></category>
  </view>
</template>

<script>
  import category from '@/components/module/category';
  import {
    getLicenseIdentify,
    editStore,
    storeDetail,
    mainBusiness,
	companyInfo
  } from '@/config/api2.js'
  import {
    getAreaList,getStoreType,checkBusinessLicense,downLoadEmpower,getExamineData,createExamineData,storeTypeList,pageSeo
  } from '@/config/api.js'
  import {
    imgCheck
  } from '@/plugins/upload/upload.js'
  import {downloadFun} from '@/plugins/utils.js'
  const md5 = require('../../plugins/md5.min.js');
  const defaultForm = {
	  storeType: '', //类型:0普通用户,1生产企业，2贸易企业
	  storeName: '', //商家名称
	  storeBusinessLicense:'',//营业执照
	  storeCode: '', //商家信用代码
	  registerAddress: '', //注册地址
	  bankName: '', //开户行名称
	  bankNumber: '', //开户行银行卡号
	  contactPerson: '', //联系人
	  storePhone: '', //联系电话
	  mainBusiness: '', //主营业务
	  empowerBook:'',//授权书
	  brandAgency:'',//品牌代理
	  procurementChannels:'',//采购渠道
	  invoicePhone:'', //发票电话 
	  checkRemark:'',
	  website:'',
	  businessAddressImg:'',
	  warehouseImg:[],
	  technicalPatentsImg:[],
	  honorImg:[],
	  regTime:''
  }
  export default {
	  filters:{
		  fiftype(val){
			  if(val == 1){
				  return '生产厂家'
			  }else if(val == 2){
				  return '品牌代理'
			  }else if(val == 3){
				  return '优选供应商'
			  }else if(val == 4){
				  return '普通供应商'
			  }
		  },
		  fiftypeyear(val){
			  if(val == 1){
				return '5'
			  }else if(val == 2){
			    return '5'
			  }else if(val == 3){
				return '3'
			  }else if(val == 4){
				return '1.5'
			  }
		  },
	  },
    data() {
      return {
        fileList1: [],
        storeId: 0,
        list: [],
        mainBusiness: [],
        mainBusinessLi: [],
        current: 0,
        restart: true,
        uploadImgUrl: "https://pic.gxmore.com/FiqGX7sq-tf7AxckbXJHCroBW1Pv",
        businessInfo: {},
		model1: JSON.parse(JSON.stringify(defaultForm)),
		rules: {
		 'storeBusinessLicense': {
		   type: 'string',
		   required: true,
		   message: '请上传营业执照',
		   trigger: ['blur', 'change']
		 },
		 'registerAddress': {
		    type: 'string',
		    required: true,
		    message: '请输入开票信息注册地址',
		    trigger: ['blur', 'change']
		  },
		  // 'storeArea': {
		  //   type: 'string',
		  //   required: true,
		  //   message: '请选择所在地区',
		  //   trigger: ['blur', 'change']
		  // },
		  // 'storeAddress': {
		  //   type: 'string',
		  //   required: true,
		  //   message: '请输入详细地址',
		  //   trigger: ['blur', 'change']
		  // },
		  'invoicePhone': {
		    type: 'string',
		    required: true,
		    message: '请输入开票信息联系电话',
		    trigger: ['blur', 'change']
		  },
		  'bankName': {
		    type: 'string',
		    required: true,
		    message: '请输入开户行',
		    trigger: ['blur', 'change']
		  },
		  'bankNumber': {
		    type: 'string',
		    required: true,
		    message: '请输入开户行帐号',
		    trigger: ['blur', 'change']
		  },
		  'contactPerson': {
		    type: 'string',
		    required: true,
		    message: '请输入联系人',
		    trigger: ['blur', 'change']
		  },
		  'storePhone': {
		    type: 'string',
		    required: true,
		    message: '请输入联系人电话',
		    trigger: ['blur', 'change']
		  },
		  'mainBusiness': {
		    type: 'string',
		    required: true,
		    message: '请选择主营业务',
		    trigger: ['blur', 'change']
		  },
		  'storeType': {
		    type: 'string',
		    required: true,
		    message: '选择店铺类型',
		    trigger: ['blur', 'change']
		  },
		  'empowerBook': {
		    type: 'string',
		    required: true,
		    message: '请上传授权书',
		    trigger: ['blur', 'change']
		  },
		  'brandAgency': {
		    type: 'string',
		    required: true,
		    message: '请上传品牌代理文件',
		    trigger: ['blur', 'change']
		  },
		  'procurementChannels': {
		    type: 'string',
		    required: true,
		    message: '请上传采购渠道文件',
		    trigger: ['blur', 'change']
		  },
		  'businessAddressImg':{
			  type: 'string',
			  required: true,
			  message: '请上传实体经营地址照片',
			  trigger: ['blur', 'change']
		  }
		},
		dataTree:[],
		showStoreType:false,
		columns: [],
		isEdit:false,
		storeType:'',
		wordFile:'',
		storeState:'',
		typeList:{}
		
      }
    },
    onLoad(e) {
		if(e.companyId){
			this.getCompanyInfo(e.companyId)
		}else{
			this.getStoreDetail()
		}
		  this.getDataList()
		  this.columns = [];
		  getStoreType().then((res)=>{
			  this.columns.push(res)
		  })
		  downLoadEmpower().then((res)=>{
			  this.wordFile = res.fileUrl
		  })
		  this.getTypeList()
		  // #ifdef H5
		  pageSeo({pageType: 'indexPage'}).then((res)=>{
		  	document.title = res.pageTitle;
		  })
		  // #endif	
    },
    components: {
      category
    },
    methods: {
			getTypeList(){
			  return storeTypeList().then((res)=>{
				  this.typeList = res
			  })
			},
			//上传图片
			handleAfterRead2(event,key) {
				if(event.file.size>2*1024*1000){
					uni.showToast({
						title:'图片大小超过2M，请重新选择照片',
						icon:'none'
					})		
					return
				}
				uni.showLoading({
					title: '上传中',
				});
				imgCheck(event.file.url).then((res)=>{
					this.model1[key].push({url:res})
					uni.hideLoading()
				}).catch(()=>{
					uni.hideLoading()
				})
			},
			
			//删除图片
			deleteImg(event,key){
				this.model1[key].splice(event.index,1)
			},
		
		  // 认证公司详情
		  getCompanyInfo(companyId) {
		    companyInfo({companyId }).then(res => {
			  this.model1 = JSON.parse(JSON.stringify(defaultForm))
		      this.model1.storeName = res.companyName
		      this.model1.storeCode = res.licenseCode
			  this.model1.registerAddress = res.regAddress
			  this.model1.bankName = res.bankName
			  this.model1.bankNumber = res.bankNumber
			  this.model1.storeBusinessLicense = res.businessLicense
			  this.model1.invoicePhone = res.regPhone
		      this.isEdit = true
		    })
		  },
	
		
		getStoreDetail() {
		  getExamineData().then(res => {
					if(res){
						this.mainBusinessLi = res.mainBusiness
						this.storeState = res.storeState
					    for(let key  in defaultForm){
						    this.model1[key] = res[key] ? res[key] : defaultForm[key]
						}
						// this.model1 = JSON.parse(JSON.stringify(res))
						this.model1.mainBusiness = res.mainBusinessStr ? res.mainBusinessStr.join(',') : '';
						console.log("res.mainBusiness",res.mainBusiness)
						res.mainBusiness.forEach((item, index) => {
						  this.list.push({
						    categoryId: item,
						    categoryName: res.mainBusinessStr[index]
						  })
						});
						this.storeType = res.storeType 
						if(this.storeType == 1){
							this.model1.storeType = '生产厂家'
						}else if(this.storeType == 2){
							this.model1.storeType = '品牌代理'
						}else if(this.storeType == 3){
							this.model1.storeType = '优选供应商'
						}else if(this.storeType == 4){
							this.model1.storeType = '普通供应商'
						}
						console.log(this.model1.storeType)
						this.model1.warehouseImg = []
						this.model1.technicalPatentsImg = []
						this.model1.honorImg= []
						res.warehouseImg.forEach((el)=>{
							this.model1.warehouseImg.push({url:el})
						})
						res.technicalPatentsImg.forEach((el)=>{
							this.model1.technicalPatentsImg.push({url:el})
						})
						res.honorImg.forEach((el)=>{
							this.model1.honorImg.push({url:el})
						})
						this.isEdit = false
					}else{
						this.model1 = JSON.parse(JSON.stringify(defaultForm))
						this.storeType = 4
						if(this.storeType == 1){
							this.model1.storeType = '生产厂家'
						}else if(this.storeType == 2){
							this.model1.storeType = '品牌代理'
						}else if(this.storeType == 3){
							this.model1.storeType = '优选供应商'
						}else if(this.storeType == 4){
							this.model1.storeType = '普通供应商'
						}
						this.isEdit = true
					}
					console.log(this.isEdit)
		  })
		},
		
		preview(url){
			uni.previewimg({urls: [url]});
		},
		preview2(url){
			let list = []
			url.forEach((el)=>{
				list.push(el.url)
			})
			uni.previewimg({urls: lists});
		},
		// 下载
		downImg() {
			downloadFun(this.wordFile)
		},
		// 点击选择公司类型
		changeStore() {
			if(this.isEdit){
				this.showStoreType = true
			}
		  
		},
		// 公司类型选择确定后触发
		confirmStoreType(e) {
		  console.log('e3', e)
		  if(this.storeType != e.value[0].id){
			  this.model1 = JSON.parse(JSON.stringify(defaultForm))
		  }
		  this.storeType = e.value[0].id
		  this.model1.storeType = e.value[0].value
		  this.showStoreType = false;
		 
		},
		cancelStoreType(e) {
		  this.showStoreType = false
		},
		
		getDataList() {
		  getAreaList({
		    custom: false
		  }).then((res) => {
		    this.dataTree = res;
		  })
		},
		onchange(e) {
			if(this.isEdit){
				let ids = [];
				let txts = [];
				e.detail.value.forEach((item) => {
				  txts.push(item.text)
				  ids.push(item.value)
				});
				// this.provinceId = ids[0] ? ids[0] : ''
				// this.cityId = ids[1] ? ids[1] : ''
				// this.areaId = ids[2] ? ids[2] : ''
				this.model1.storeArea = txts.join(" ")
			} 
		},
		showMainBu() {
			if(this.isEdit ){
				if(this.storeType != ''){
					this.$refs.category.init('more', this.list,this.storeType);
				}else{
					uni.showToast({
							title: '请先选择店铺类型',
							icon: 'none'
					});
				}
				
			}
		  
		},
		
		
		//选择品名
		chooseCategory(list) {
		  this.list = list
		  this.mainBusinessLi = []
		  const arr1 = []
		  list.forEach(item => {
		    this.mainBusinessLi.push(item.categoryId)
		    arr1.push(item.categoryName)
		  })
		  this.model1.mainBusiness = arr1.join(',')
		},
		handleAfterRead(event,key) {
			if(event.file.size>2*1024*1000){
				uni.showToast({
					title:'图片大小超过2M，请重新选择照片',
					icon:'none'
				})		
				return
			}
			uni.showLoading({
				title: '上传中',
			});
			console.log("event",event)
			console.log("key",key)
			imgCheck(event.file.url).then((res)=>{
				if(res != ''){
					this.model1[key] = res;
					if(key == 'storeBusinessLicense'){
						const licensePicUrl = res;
						// 生成签名串
						const encryption = md5(licensePicUrl + "gxmore..!");
						this.getLicenseIdentifys(licensePicUrl, encryption)
					}
					
				}
				uni.hideLoading()
			}).catch(()=>{
				uni.hideLoading()
			})
		},
		
		//营业执照识别
      getLicenseIdentifys(data1, data2) {
        checkBusinessLicense({
          licensePicUrl: data1,
          encryption: data2
        }).then(res => {
          this.model1.storeName = res.companyName
          this.model1.storeCode = res.creditCode
          this.model1.registerAddress = res.companyAddress
		  this.model1.regTime = res.regTime
        }).catch(()=>{
			this.model1.storeBusinessLicense = ''
		})
      },
	
      addEditStore() {
        let data = JSON.parse(JSON.stringify(this.model1))
		data.storeType = this.storeType;
		data.mainBusiness = this.mainBusinessLi;
		data.warehouseImg = [];
		data.technicalPatentsImg = [];
		data.honorImg = [];
	    this.model1.warehouseImg.forEach((el)=>{
			data.warehouseImg.push(el.url)
		})
		this.model1.technicalPatentsImg.forEach((el)=>{
			data.technicalPatentsImg.push(el.url)
		})
		this.model1.honorImg.forEach((el)=>{
			data.honorImg.push(el.url)
		})
		console.log("data",data)
		this.$refs.uForm.validate().then(res => {
		  createExamineData(data).then(res => {
		    uni.$u.toast('提交成功')
			this.getStoreDetail()
		  })
		}).catch(errors => {
	 
		}) 

      },
      againEditStore() {
        this.businessInfo = {}
        this.mainBusiness = []
        this.mainBusinessLi = []
        this.list = []
      },
    
    },

  }
</script>

<style>
	
</style>
<style lang="scss">
  @import '@/style/wmj.scss';
  .checkIn-info{
	  background: linear-gradient(180deg, #fffbf5 0%, #FFFFFF 10%);
	  box-shadow: 0px 0px 10px rgba(0,17,52,0.09);
	  padding:32rpx;
	  padding-bottom:160rpx;
	  .checkIn-state{
		  padding:40rpx;
		  border-bottom:2rpx dashed #DEDEDE;
		  text-align: center;
		  font-weight: bold;
		  .state-stext{
			  font-size:24rpx;
			  color:#888;
			  text-align: center;
			  padding:32rpx;
			  font-weight: 400;
		  }
	  }
  }
   .checkIn-business{
	   padding:0 32rpx;
	   padding-bottom:160rpx;
	   .form-bg{
		   background: #fff;
		   border-radius: 18rpx;
		   box-shadow: 0px 0px 15rpx rgba(0,17,52,0.15);
		   padding:0 32rpx;
	   }
   }
  .content-top {
    .row {
      width: 100%;
      padding: 0 24rpx;
      border-top: solid 1upx #eee;

      .nominal {
        width: 30%;
        height: 90upx;
        font-size: 30upx;
        text-align: left;
        line-height: 90upx;
      }

      .input {
        width: 100%;
        padding: 20upx 0;
        align-items: center;
        font-size: 30upx;
        text-align: right;

      }



    }
  }

  .butoon-bottom {
    width: 100%;
    padding: 20px;
    position: fixed;
    bottom: 0;
  }

  .mainBu-content {
    display: flex;
    padding: 0;

    .mainBu-content-left {
      border-right: 1px solid #cccccc;

      .scroll-view-y {
        min-height: 300px;

        .button {
          margin: 14px 20px 25px 10px;
          padding-bottom: 5px;
          font-size: 26rpx;
          color: #929292;
        }

        .active {
          border-bottom: 2px solid #FF5E01;
          color: #FF5E01;
        }
      }

    }

    .mainBu-content-right {
      padding: 0 !important;

      .scroll-view-y {
        height: 300px;



        .right-text {
          margin: 5px 10px;
          display: inline-block;
          font-size: 26rpx;
          color: #ababab;

          view {
            padding: 5px;
          }
        }

        .choonse {
          color: #FF5E01;
        }
      }

      width: 200px;
      flex: 1;
      padding: 20px;



    }
  }
</style>